//
//  DDChangePhoneAlert.m
//  DingDongZP
//
//  Created by 杨政涛 on 16/8/12.
//  Copyright © 2016年 51ledian.com. All rights reserved.
//

#import "DDChangePhoneAlert.h"

@implementation DDChangePhoneAlert

- (instancetype)initWithCreatDDChangePhoneAlertframe:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.windowShadowView = [[UIView alloc] init];
        self.windowShadowView.userInteractionEnabled = YES;
        self.windowShadowView.hidden = YES;
        self.windowShadowView.frame = frame;
        self.windowShadowView.backgroundColor = [UIColor colorWithWhite:0.000 alpha:0.3500];
        AppDelegate *app=(AppDelegate *)[UIApplication sharedApplication].delegate;
        [app.window.rootViewController.view addSubview:self.windowShadowView];
     
        
        UIView *inner = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 250, 100)];
        inner.backgroundColor = [UIColor whiteColor];
        inner.layer.masksToBounds = YES;
        inner.layer.cornerRadius = 10.0;
        inner.center = self.windowShadowView.center;
        [self.windowShadowView addSubview:inner];
        
        self.infoLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 10, CGRectGetWidth(inner.bounds), 40)];
        self.infoLab.textAlignment = NSTextAlignmentCenter;
        self.infoLab.font = [UIFont systemFontOfSize:17];
        self.infoLab.textColor = COLOR_FONT_BLACK;
        self.infoLab.numberOfLines = 0;
        [inner addSubview:self.infoLab];
        
        UIView *sep1 = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.infoLab.frame)+10, 250, 0.5)];
        sep1.backgroundColor = [UIColor lightGrayColor];
        [inner addSubview:sep1];
        
        UIView *sep2 = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetWidth(inner.bounds)/2,CGRectGetMaxY(sep1.frame), 0.5, 40)];
        sep2.backgroundColor = [UIColor lightGrayColor];
        [inner addSubview:sep2];
        
        UIButton *accept = [UIButton setDetailsBtn:@"取消" picName:nil btnBackColor:nil titleColor:[UIColor colorWithRed:1.000 green:0.255 blue:0.255 alpha:1.000]];
        accept.tag = 10;
        accept.frame = CGRectMake(0,CGRectGetMaxY(sep1.frame), CGRectGetWidth(inner.bounds)/2, 40);
        [inner addSubview:accept];
        [accept addTarget:self action:@selector(cancleAction:) forControlEvents:UIControlEventTouchUpInside];
        
        UIButton *refuse = [UIButton setDetailsBtn:@"确定" picName:nil btnBackColor:nil titleColor:[UIColor colorWithRed:0.188 green:0.682 blue:0.678 alpha:1.000]];
        refuse.tag = 11;
        refuse.frame = CGRectMake(CGRectGetWidth(inner.bounds)/2, CGRectGetMaxY(sep1.frame),CGRectGetWidth(inner.bounds)/2, 40);
        [inner addSubview:refuse];
        [refuse addTarget:self action:@selector(sureAction:) forControlEvents:UIControlEventTouchUpInside];
        
    }
    return self;

}

- (void)cancleAction:(id)sender {

    self.windowShadowView.hidden = YES;
    
}

- (void)sureAction:(id)sender {
 
    self.windowShadowView.hidden = YES;
    /**
     *  发送一个确定交换的通知
     */
    if ([self.infoLab.text isEqualToString:@"确定交换电话？"]) {
        [[NSNotificationCenter defaultCenter]postNotificationName:@"DDchangePhone" object:nil userInfo:nil];
    }
    if ([self.infoLab.text isEqualToString:@"确定交换微信？"]) {
        [[NSNotificationCenter defaultCenter]postNotificationName:@"DDchangeWeiXin" object:nil userInfo:nil];
    }
    
    /**
     *   邀约面试  只能Boss端发起     视频面试功能 两端都可以发起
     */
    if ([self.infoLab.text isEqualToString:@"确定在线面试吗？"]) {
        [[NSNotificationCenter defaultCenter]postNotificationName:@"DDOnlineVideoInterview" object:nil userInfo:nil];
    }
    if ([self.infoLab.text isEqualToString:@"确定要和牛人约面试吗？"]) {
        [[NSNotificationCenter defaultCenter]postNotificationName:@"DDInvitationInterview" object:nil userInfo:nil];
    }
}

@end
